//
//  DYSingleColorView.m
//  colorTest
//
//  Created by 丁益 on 2017/4/11.
//  Copyright © 2017年 celi. All rights reserved.
//
#import "DYSingleColorView.h"

@interface  DYSingleColorView()
@property (nonatomic,weak) UILabel *colorValueLabel;
@end

@implementation DYSingleColorView

- (id) initWithFrame:(CGRect)frame selectColorWithValue:(NSString *)colorValue color:(UIColor *)color
{
    if (self = [super initWithFrame:frame]) {
        
        CGFloat labelHeight = frame.size.height;
        CGFloat labelWidht = frame.size.width;
        UILabel *colorLabel = [[UILabel alloc]initWithFrame:CGRectMake(0, 0, labelWidht, labelHeight)];
        UILabel *colorLabelTitel = [[UILabel alloc] initWithFrame:CGRectMake(0, 0,15, labelHeight)];
        colorLabelTitel.text = @"R";
        colorLabelTitel.textColor = [UIColor whiteColor];
        colorLabelTitel.backgroundColor = [UIColor colorWithRed:88/255.0 green:88/255.0 blue:88/255.0 alpha:0.8];
        colorLabel.backgroundColor = color;
        [self addSubview:colorLabel];
        [self addSubview:colorLabelTitel];
        CGFloat redValueX = CGRectGetMaxX(colorLabelTitel.frame);
        UILabel *colorValueLabel = [[UILabel alloc] initWithFrame:CGRectMake(redValueX,0,labelWidht-15, labelHeight)];
        colorValueLabel.text = colorValue;
        colorValueLabel.textColor = [UIColor whiteColor];
        [colorValueLabel setFont:[UIFont systemFontOfSize:14]];
        [self addSubview:colorValueLabel];
        self.colorValueLabel = colorValueLabel;
        
    }
    
    return self;
}

- (void)setColorValue:(NSString *)value
{
    self.colorValueLabel.text = value;
}

@end
